package daobeauty.interceptor.invoke;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;

public abstract class AbstractCurrentSessionInvokeStrategy implements InvokeStrategy {
	private final SessionFactory sessionFactory;
	private final Class domainClass;
	
	public AbstractCurrentSessionInvokeStrategy(SessionFactory sessionFactory, Class domainClass){
		this.sessionFactory = sessionFactory;
		this.domainClass = domainClass;
	}
	
	public Session getCurrentSession(){
		return sessionFactory.getCurrentSession();
	}
	
	public Criteria createCriteria(){
		return getCurrentSession().createCriteria(domainClass);
	}
	
	public Class getDomainClass(){
		return domainClass;
	}
}
